#include <stdarg.h>
#include <cstdint.h>
#include <string.h>
#include <_stdlib.h>
#include "text_video.h"
void utoa(unsigned int value,int base,char *str);
void utoa_s(int value,int base,char *str);
int ttprintf (const char* str, ...){
	return 0;
}
int dprintf (const char* str, ...) {
	char c;
	char strz[64];
	int iii;
	size_t i;
	va_list		args;
	if(!str)
		return 0;
	va_start (args, str);
	for (i=0; i<strlen(str);i++) {

		switch (str[i]) {

			case '%':

				switch (str[i+1]) {

					/*** characters ***/
					case 'c': {
						c = va_arg (args, char);
						dputch (c);
						i++;		// go to next character
						break;
					}

					/*** address of ***/
					case 's': {
						iii = (uint32_t) va_arg (args, uint32_t);
						dprintf ((const char*)iii);
						i++;		// go to next character
						break;
					}

					/*** integers ***/
					case 'd':
					case 'i': {
						iii = va_arg (args, int);
						utoa_s (iii, 10, strz);
						dprintf (strz);
						i++;		// go to next character
						break;
					}

					/*** display in hex ***/
					case 'X':
					case 'x': {
						iii = va_arg (args, int);
						utoa (iii,16,strz);
						dprintf (strz);
						i++;		// go to next character
						break;
					}

					default:
						va_end (args);
						return 1;
				}

				break;

			default:
				dputch (str[i]);
				break;
		}

	}

	va_end (args);
	return i;
}